package supercafe.core;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Vector;

import supercafe.dataprovider.FinishGet;
import supercafe.dataprovider.DataGetter;
import supercafe.defines.URLs;


import android.app.Activity;

public class AllMenus {
	private static Vector<MenuType> menus = null;
	private static AllMenus instance;
	public static AllMenus getInstance(){
		if(instance!=null){
			return instance;
		}
		return (instance=new AllMenus());
	}
	public static void requestMenus(Activity activity, String url) {
		DataGetter dg = new DataGetter(null,activity);
		dg.execute(url);//"http://192.168.1.53/admin/types/retrieve"
		while(!dg.isFinished()){
			try{
				Thread.sleep(500);
			}catch (Exception e) {
			}
		}
		menus = XMLHandler.getListMenus(activity, dg.getResponseResult());
	}
	
	public static Vector<MenuType> getMenus(Activity activity) {
		if(menus==null || menus.isEmpty())
			requestMenus(activity,URLs.GET_ALL_MENUS);
		return menus;
	}
	
	public static Vector<MenuType> getNewMenus(Activity activity) {
		requestMenus(activity,URLs.GET_ALL_MENUS);
		return menus;
	}
}